package com.bucg.cjcloud.gb28181.sip.process;

import com.bucg.cjcloud.gb28181.sip.modle.ResponseModel;
import com.bucg.cjcloud.gb28181.sip.handler.KeepaliveHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.sip.message.Request;

@Component
@Order(1)
public class KeepaliveRequestProcess implements RequestProcess{
	@Autowired
	KeepaliveHandler keepaliveHandler;

	@Override
	public ResponseModel processRequest(Request req, String cmdType) {
		keepaliveHandler.handler(null,req);
		return ResponseModel.builder().statusCode(200).build();
	}
	
	@Override
	public boolean isSupport(Request req, String cmdType) {
		String method = req.getMethod();
		String content = String.valueOf(req.getContent());
		String content1 = content;
		return   cmdType != null &&cmdType.equalsIgnoreCase("keepalive");

		// boolean b = Request.MESSAGE.equals(method) && content1 != null && content1.contains("CmdType") && content1.contains("Keepalive");
		// return b;
	}
	
	
}
